// 
//  main.cpp
//  LoginSecurity
//  
//  Created by Ryan Latta on 2008-12-01.
//  Copyright 2008 Ryan Latta. All rights reserved.
// 

#include "Security.h"
#include <iostream>
/*
  TODO insert Pam functions
  TODO handle arguments from pam.conf files
  TODO understand that pam_conv function.
  TODO Make sure that when its done you set that this module succeeded or failed for other modules
  TODO Make PAM Compliant
  TODO test test test
*/


int main () {
  string input;
  float correctAnswers = 0;
  float totalQuestions = 5;
  float threshold = .7;
  
  QuestionFactory *qf = new QuestionFactory();
  Question* q = qf->getQuestion();
  
  cout << "Answer the following question: " << endl;
  cout.precision(2);
  
  for(int i = 0; i < totalQuestions; i++) {
    q->makeQuestion();
    cout << q->getQuestion();
    cin >> input;
  
    if(q->getAnswer() == (input)) {
        cout << "Correct." << endl;
        correctAnswers++;
      }
    else {
      cout << "Incorrect." << endl;
    }
  }
  
  cout << "You answered " << correctAnswers << " out of " << totalQuestions << endl;
  
  if(correctAnswers/totalQuestions < threshold) {
    cout << "You missed too many questions." << endl;
  }
  q = NULL;
  free(q);
  delete qf;

  return 0;
}

